<template>
	<view class="pageView">
		<u-loading-page :loading="peiPeopleLoading" bg-color="#e8e8e8"></u-loading-page>
		<u-navbar
			title="就诊人列表"
			@leftClick="handleLeftClick"
		>
		</u-navbar>
		<view v-if="peopleList.length == 0" class="emptyBlock">
			<image src="https://bucketoss10086.oss-cn-beijing.aliyuncs.com/images/emptyHos.png"></image>
			<view class="emptyFont">暂无陪诊师</view>
		</view>
		<view v-else>
			<scroll-view class="listBlock">
				<view class="listBlockItem" v-for="(item, index) in peopleList" :key="index">
					<view class="listBlockItem-valBlock">
						<view class="listBlockItem-valBlock-username">{{ item.name }}</view>
						<view class="listBlockItem-valBlock-bottomBlock">
							<view class="listBlockItem-valBlock-bottomBlock-left">{{ item.gender|handleGender }}</view>
							<view class="listBlockItem-valBlock-bottomBlock-right">{{ item.mobile }}</view>
						</view>
					</view>
					<view class="listBlockItem-btnBlock">
						<button class="listBlockItem-btnBlock-rightBtn" @click="handleClickChoose(item)">选择</button>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import { partner } from '@/api/common.js'
	export default{
		data() {
			return {
				page: 1,
				peiPeopleLoading: false,
				peopleList: []
			}
		},
		filters: {
			handleGender(val) {
				if (val == 1) {
					return '男'
				} else {
					return '女'
				}
			}
		},
		onShow() {
			this.page = 1
			this.peopleList = []
			this.getList()
		},
		methods: {
			getList() {
				this.peiPeopleLoading = true
				partner({
					page: this.page
				})
				.then(res => {
					const { code, data } = res
					if (code == 200001) {
						if (this.peopleList.length == 0) {
							this.peopleList = data.data
						} else {
							this.peopleList = this.peopleList.concat(data.data)
						}
					}
					this.peiPeopleLoading = false
				})
				.catch(e => {
					this.peiPeopleLoading = false
				})
			},
			handleAddPeople() {
				uni.removeStorageSync('peopleEdit', item)
				uni.navigateTo({
					url: '/pages/addPeople/addPeople'
				})
			},
			handleEditPeople(item) {
				uni.setStorageSync('peopleEdit', item)
				uni.navigateTo({
					url: '/pages/addPeople/addPeople'
				})
			},
			handleClickChoose(item) {
				uni.setStorageSync('peiPeopleItem', item)
				uni.navigateTo({
					url: '/pages/createOrder/createOrder'
				})
			},
			handleLeftClick() {
				uni.navigateTo({
					url: '/pages/createOrder/createOrder'
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.pageView{
		height: 100vh;
		background: #F4F4F4;
		.emptyBlock{
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			height: 89vh;
			margin-top: 176rpx;
			image{
				width: 360rpx;
				height: 240rpx;
			}
			.emptyFont{
				padding-top: 48rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #727687;
			}
			button{
				display: flex;
				align-items: center;
				justify-content: center;
				margin-top: 80rpx;
				width: 240rpx;
				height: 80rpx;
				background: #0165FB;
				border-radius: 30px;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #FFFFFF;
			}
		}
		.listBlock{
			height: 81vh;
			margin-top: 176rpx;
			.listBlockItem{
				padding: 32rpx;
				margin-top: 30rpx;
				background: #fff;
				border-radius: 15px;
				display: flex;
				justify-content: space-between;
				&-valBlock{
					&-username{
						font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
						font-weight: normal;
						font-size: 32rpx;
						color: #222222;
					}
					&-bottomBlock{
						display: flex;
						align-items: center;
						padding-top: 16rpx;
						&-left{
							padding-right: 16rpx;
							font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
							font-weight: normal;
							font-size: 28rpx;
							color: #222222;
							border-right: 2px solid #DFDFDF;
						}
						&-middle{
							padding: 0px 16rpx;
							font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
							font-weight: normal;
							font-size: 28rpx;
							color: #222222;
							border-right: 2px solid #DFDFDF;
						}
						&-right{
							padding-left: 16rpx;
							font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
							font-weight: normal;
							font-size: 28rpx;
							color: #222222;
						}
					}
				}
				&-btnBlock{
					display: flex;
					align-items: center;
					&-leftBtn{
						font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
						font-weight: normal;
						font-size: 28rpx;
						color: #0165FB;
						margin-right: 14rpx;
					}
					&-rightBtn{
						display: flex;
						justify-content: center;
						align-items: center;
						width: 112rpx;
						height: 50rpx;
						background: #0165FB;
						border-radius: 60rpx 60rpx 60rpx 60rpx;
						font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
						font-weight: normal;
						font-size: 24rpx;
						color: #FFFFFF;
					}
				}
			}
		}
		.btnBlockChoose{
			padding: 20rpx 30rpx;
			background: #fff;
			button{
				display: flex;
				justify-content: center;
				align-items: center;
				width: 690rpx;
				height: 78rpx;
				background: #0165FB;
				border-radius: 68rpx 68rpx 68rpx 68rpx;
				font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
				font-weight: normal;
				font-size: 30rpx;
				color: #FFFFFF;
			}
		}
	}
</style>